//
//  homeModel.m
//  XYMaterial
//
//  Created by 肖扬 on 15/12/11.
//  Copyright © 2015年 肖扬. All rights reserved.
//

#import "homeModel.h"

@implementation homeModel
@synthesize data;
-(id)init{
    self = [super init];
    if (self) {
        self.data = [NSMutableDictionary dictionary];
    }
    return self;
}
-(void)parseResponseData:(NSString *)responseString{
    [super parseResponseData:responseString];
    NSMutableDictionary *dic = [responseString objectFromJSONString];
    NSDictionary * dict = [dic objectForKey:@"data"];
    NSMutableArray *tempBanner = [dict objectForKey:@"banner"];
    NSMutableArray *tempSupply = [dict objectForKey:@"supply"];
    NSMutableArray *hot_keywords = [dict objectForKey:@"hot_keywords"];
    NSMutableArray *banner = [NSMutableArray array];
    NSMutableArray *supply = [NSMutableArray array];
    if ([tempBanner count]!=0) {
        for (int i = 0; i < [tempBanner count]; i++) {
            NSMutableDictionary * bannerDic = [tempBanner objectAtIndex:i];
            homeModelBanner *homeBanner = [[homeModelBanner alloc]init];
            homeBanner.image_url = [bannerDic objectForKey:@"image_url"];
            homeBanner.link_url = [bannerDic objectForKey:@"link_url"];
            [banner addObject:homeBanner];
        }
    }
    
    for (int k = 0; k < [tempSupply count]; k++) {
        NSMutableDictionary * supplyDic = [tempSupply objectAtIndex:k];
        homeModelSupply *homeSupply = [[homeModelSupply alloc]init];
        homeSupply.pics = [supplyDic objectForKey:@"pics"];
        homeSupply.home_id = [supplyDic objectForKey:@"id"];
        homeSupply.mid = [supplyDic objectForKey:@"mid"];
        homeSupply.material_id = [supplyDic objectForKey:@"material_id"];
        homeSupply.brand_id = [supplyDic objectForKey:@"brand_id"];
        
        homeSupply.image_url = [supplyDic objectForKey:@"image_url"];
        
        homeSupply.brand_other = [supplyDic objectForKey:@"brand_other"];
        homeSupply.producer_id = [supplyDic objectForKey:@"producer_id"];
        homeSupply.future = [supplyDic objectForKey:@"future"];
        homeSupply.model = [supplyDic objectForKey:@"model"];
        homeSupply.eplevel = [supplyDic objectForKey:@"eplevel"];
        
        homeSupply.texture = [supplyDic objectForKey:@"texture"];
        homeSupply.unit_number = [supplyDic objectForKey:@"unit_number"];
        homeSupply.stuff = [supplyDic objectForKey:@"stuff"];
        homeSupply.veneer = [supplyDic objectForKey:@"veneer"];
        homeSupply.gram = [supplyDic objectForKey:@"gram"];
        homeSupply.length = [supplyDic objectForKey:@"length"];
        
        homeSupply.width = [supplyDic objectForKey:@"width"];
        homeSupply.thickness = [supplyDic objectForKey:@"thickness"];
        homeSupply.number = [supplyDic objectForKey:@"number"];
        homeSupply.min_buy_number = [supplyDic objectForKey:@"min_buy_number"];
        homeSupply.price = [supplyDic objectForKey:@"price"];
        
        homeSupply.province = [supplyDic objectForKey:@"province"];
        homeSupply.city = [supplyDic objectForKey:@"city"];
        homeSupply.remark = [supplyDic objectForKey:@"remark"];
        homeSupply.is_sales = [supplyDic objectForKey:@"is_sales"];
        homeSupply.producer_name = [supplyDic objectForKey:@"producer_name"];
        
        homeSupply.material_name = [supplyDic objectForKey:@"material_name"];
        homeSupply.brand_name = [supplyDic objectForKey:@"brand_name"];
        homeSupply.province_name = [supplyDic objectForKey:@"province_name"];
        homeSupply.city_name = [supplyDic objectForKey:@"city_name"];
        homeSupply.pubtime_int = [supplyDic objectForKey:@"pubtime_int"];
        homeSupply.unit = [supplyDic objectForKey:@"unit"];
        homeSupply.price2 = [supplyDic objectForKey:@"price2"];
        homeSupply.surface = [supplyDic objectForKey:@"surface"];
        homeSupply.title = [supplyDic objectForKey:@"title"];
        
        
        homeSupply.no = [supplyDic objectForKey:@"no"];
        homeSupply.supplier_mid = [supplyDic objectForKey:@"supplier_mid"];
        homeSupply.purchaser_mid = [supplyDic objectForKey:@"purchaser_mid"];
        homeSupply.amount = [supplyDic objectForKey:@"amount"];
        homeSupply.post_address = [supplyDic objectForKey:@"post_address"];
        homeSupply.freight = [supplyDic objectForKey:@"freight"];
        homeSupply.payment_type = [supplyDic objectForKey:@"payment_type"];
        homeSupply.payment_id = [supplyDic objectForKey:@"payment_id"];
        homeSupply.supply_id = [supplyDic objectForKey:@"supply_id"];
        
        homeSupply.purchase_id = [supplyDic objectForKey:@"purchase_id"];
        homeSupply.creator = [supplyDic objectForKey:@"creator"];
        homeSupply.mender = [supplyDic objectForKey:@"mender"];
        homeSupply.nickname = [supplyDic objectForKey:@"nickname"];
        homeSupply.company_name = [supplyDic objectForKey:@"company_name"];
        homeSupply.ctime_int = [supplyDic objectForKey:@"ctime_int"];
        
        [supply addObject:homeSupply];
    }
    [self.data setObject:banner forKey:@"banner"];
    [self.data setObject:supply forKey:@"supply"];
//    [self.data setObject:hot_keywords forKey:@"hot_keywords"];
}
-(void)dealloc{
    [self.data removeAllObjects];
    self.data = nil;
}
@end

@implementation homeModelBanner

@synthesize image_url,link_url;
-(void)dealloc{
    self.image_url = nil;
    self.link_url = nil;
}

@end

@implementation homeModelSupply

@synthesize home_id,mid,material_id,brand_id,brand_other;
@synthesize producer_id,future,model,eplevel,texture;
@synthesize unit_number,veneer,gram,length,width;
@synthesize thickness,number,min_buy_number,price,province;
@synthesize city,remark,is_sales,producer_name,material_name;
@synthesize brand_name,pics,province_name,city_name;
@synthesize image_url,stuff,pubtime_int,unit;
// 额外添加字段
@synthesize surface,price2,title;
// 额外添加订单的字段
@synthesize no,supplier_mid,purchaser_mid,amount,post_address,freight,payment_type,supply_id,purchase_id,creator,mender,nickname,company_name,ctime_int;
-(id)init{
    self = [super init];
    if (self) {
        self.pics = [NSMutableDictionary dictionary];
    }
    return self;
}

-(void)dealloc{
    self.pics = nil;
    self.home_id = nil;
    self.mid = nil;
    self.material_id = nil;
    self.brand_id = nil;
    self.image_url = nil;
    self.stuff = nil;
    
    self.brand_other = nil;
    self.producer_id = nil;
    self.future = nil;
    self.model = nil;
    self.eplevel = nil;
    
    self.texture = nil;
    self.unit_number = nil;
    self.veneer = nil;
    self.gram = nil;
    self.length = nil;
    
    self.width = nil;
    self.thickness = nil;
    self.number = nil;
    self.min_buy_number = nil;
    self.price = nil;
    
    self.province = nil;
    self.city = nil;
    self.remark = nil;
    self.is_sales = nil;
    self.producer_name = nil;
    
    self.material_name = nil;
    self.brand_name = nil;
    self.province_name = nil;
    self.city_name = nil;

    
    self.surface = nil;
    self.price2 = nil;
    self.title = nil;
}
@end

